package com.atguigu.order.controller;


import com.atguigu.order.Order;
import com.atguigu.order.properties.OrderProperties;
import com.atguigu.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope //支持配置属性的自动
@RestController
public class OrderController {

    @Autowired
    OrderService orderService;

    @Autowired
    OrderProperties properties;

    //@Value("${order.timeout}")
    //String orderTimeout;

    @GetMapping("/config")
    public String config(){
        return "环境 "+properties.getEn()+"::"+"分组 "+properties.getGroup()+"::"+properties.getTimeout();
    }



    @GetMapping("/create")
    public Order createOrder(Long userId, Long ProductId){
        Order order = orderService.createOrder(userId, ProductId);
        return order;
    }


}
